ã¢ãã³ãªWebéçºã«ãããŠãæ©èœæ§ã®åŒ·åãã³ãŒãã®åå©çšä¿é²ãä¿å®æ§ã®åäžãå®çŸããããã®é«åºŠãªJavaScriptã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãã¿ãŒã³ãæ¢æ±ããŸãã
JavaScriptã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãã¿ãŒã³ïŒæ¯ãèãã®åŒ·å
é²åãç¶ããJavaScriptéçºã®åéã«ãããŠãã¯ãªãŒã³ã§ä¿å®æ§ãé«ããåå©çšå¯èœãªã³ãŒããæžãããšã¯éåžžã«éèŠã§ããã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãã¿ãŒã³ã¯ãJavaScriptã¢ãžã¥ãŒã«ã®ã³ã¢ããžãã¯ã倿Žããããšãªãããã®æ¯ãèãã匷åããããã®åŒ·åãªææ³ãæäŸããŸãããã®ã¢ãããŒãã¯é¢å¿ã®åé¢ãä¿é²ããã³ãŒããããæè»ã§ããã¹ããããããçè§£ãããããã®ã«ããŸãã
ã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãšã¯ïŒ
ã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãšã¯ãã¢ãžã¥ãŒã«ïŒéåžžã¯é¢æ°ãŸãã¯ã¯ã©ã¹ïŒãå ¥åãšããŠåãåãããã®ã¢ãžã¥ãŒã«ã®ä¿®æ£çãè¿ã颿°ã§ãããã³ã¬ãŒã¿ãŒã¯ãå ã®ã¢ãžã¥ãŒã«ã®ãœãŒã¹ã³ãŒããçŽæ¥å€æŽããããšãªãããã®æ¯ãèãã远å ãŸãã¯å€æŽããŸããããã¯ããœãããŠã§ã¢ãšã³ãã£ãã£ïŒã¯ã©ã¹ãã¢ãžã¥ãŒã«ã颿°ãªã©ïŒã¯æ¡åŒµã«å¯ŸããŠéããã倿Žã«å¯ŸããŠéããããã¹ãã§ããããšãããªãŒãã³ã»ã¯ããŒãºãã®ååã«æºæ ããŠããŸãã
ãã¶ã«ãããã³ã°ã远å ãããããªãã®ã ãšèããŠãã ãããããŒã¹ã®ãã¶ïŒå ã®ã¢ãžã¥ãŒã«ïŒã¯åããŸãŸã§ã远å ã®å³ãšæ©èœïŒãã³ã¬ãŒã¿ãŒã®è¿œå ïŒã§åŒ·åãããŠããŸãã
ã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒã䜿çšããå©ç¹
- ã³ãŒãã®åå©çšæ§ã®åäž: ãã³ã¬ãŒã¿ãŒã¯è€æ°ã®ã¢ãžã¥ãŒã«ã«é©çšã§ããã³ãŒãããŒã¹å šäœã§æ¯ãèãã®åŒ·åãåå©çšã§ããŸãã
- ä¿å®æ§ã®åäž: é¢å¿ãåé¢ããããšã§ããã³ã¬ãŒã¿ãŒã¯åã ã®ã¢ãžã¥ãŒã«ãšãã®åŒ·åãçè§£ãã倿Žãããã¹ãããããšã容æã«ããŸãã
- æè»æ§ã®åäž: ãã³ã¬ãŒã¿ãŒã¯ãå ã®ã¢ãžã¥ãŒã«ã®ã³ãŒãã倿Žããããšãªãæ©èœã远å ãŸãã¯å€æŽããæè»ãªæ¹æ³ãæäŸããŸãã
- ãªãŒãã³ã»ã¯ããŒãºãã®ååãžã®æºæ : ãã³ã¬ãŒã¿ãŒã䜿çšãããšãã¢ãžã¥ãŒã«ã®ãœãŒã¹ã³ãŒããçŽæ¥å€æŽããããšãªãæ©èœãæ¡åŒµã§ããä¿å®æ§ãä¿é²ãããã°ãå°å ¥ãããªã¹ã¯ã軜æžããŸãã
- ãã¹ãå®¹ææ§ã®åäž: ãã³ã¬ãŒããããã¢ãžã¥ãŒã«ã¯ããã³ã¬ãŒã¿ãŒé¢æ°ãã¢ãã¯ãŸãã¯ã¹ã¿ãåããããšã§ç°¡åã«ãã¹ãã§ããŸãã
ã³ã¢ã³ã³ã»ãããšå®è£
æ¬è³ªçã«ãã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒã¯é«é颿°ã§ãã颿°ïŒãŸãã¯ã¯ã©ã¹ïŒãåŒæ°ãšããŠåãåããæ°ããã倿Žããã颿°ïŒãŸãã¯ã¯ã©ã¹ïŒãè¿ããŸããéèŠãªã®ã¯ãå ã®é¢æ°ãæäœããæãŸããæ¯ãèãã远å ããæ¹æ³ãçè§£ããããšã§ãã
åºæ¬çãªãã³ã¬ãŒã¿ãŒã®äŸïŒé¢æ°ãã³ã¬ãŒã¿ãŒïŒ
颿°ã®å®è¡æéãèšé²ããããã«é¢æ°ããã³ã¬ãŒãããç°¡åãªäŸããå§ããŸãããã
function timingDecorator(func) {
return function(...args) {
const start = performance.now();
const result = func.apply(this, args);
const end = performance.now();
console.log(`Function ${func.name} took ${end - start}ms`);
return result;
};
}
function myExpensiveFunction(n) {
let result = 0;
for (let i = 0; i < n; i++) {
result += i;
}
return result;
}
const decoratedFunction = timingDecorator(myExpensiveFunction);
console.log(decoratedFunction(100000));
ãã®äŸã§ã¯ãtimingDecoratorããã³ã¬ãŒã¿ãŒé¢æ°ã§ããããã¯myExpensiveFunctionãå
¥åãšããŠåãåããå
ã®é¢æ°ãã©ããããæ°ãã颿°ãè¿ããŸãããã®æ°ãã颿°ã¯å®è¡æéãæž¬å®ããã³ã³ãœãŒã«ã«èšé²ããŸãã
ã¯ã©ã¹ãã³ã¬ãŒã¿ãŒïŒESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ïŒ
ECMAScriptãã³ã¬ãŒã¿ãŒããããŒã¶ã«ïŒçŸåšã¹ããŒãž3ïŒã¯ãã¯ã©ã¹ãã¯ã©ã¹ã¡ã³ããŒããã³ã¬ãŒãããããã®ãããšã¬ã¬ã³ããªæ§æãå°å ¥ããŸãããã¹ãŠã®JavaScriptç°å¢ã§ãŸã å®å šã«æšæºåãããŠããããã§ã¯ãããŸããããBabelãTypeScriptãªã©ã®ããŒã«ã«ãã£ãŠæ¯æãããæ³šç®ãéããŠããŸãã
ã¯ã©ã¹ãã³ã¬ãŒã¿ãŒã®äŸã以äžã«ç€ºããŸãã
// Requires a transpiler like Babel with the decorators plugin
function LogClass(constructor) {
return class extends constructor {
constructor(...args) {
super(...args);
console.log(`Creating a new instance of ${constructor.name}`);
}
};
}
@LogClass
class MyClass {
constructor(name) {
this.name = name;
}
greet() {
console.log(`Hello, ${this.name}!`);
}
}
const instance = new MyClass("Alice");
instance.greet();
ãã®ã±ãŒã¹ã§ã¯ã@LogClassã¯MyClassã«é©çšããããã³ã¬ãŒã¿ãŒã§ãã¯ã©ã¹ã®æ°ããã€ã³ã¹ã¿ã³ã¹ãäœæããããã³ã«ã¡ãã»ãŒãžãèšé²ããããã«ã³ã³ã¹ãã©ã¯ã¿ãŒã匷åããŸãã
ã¡ãœãããã³ã¬ãŒã¿ãŒïŒESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ïŒ
ã¯ã©ã¹å ã®åã ã®ã¡ãœããããã³ã¬ãŒãããããšãã§ããŸãã
// Requires a transpiler like Babel with the decorators plugin
function LogMethod(target, propertyKey, descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function(...args) {
console.log(`Calling method ${propertyKey} with arguments: ${args}`);
const result = originalMethod.apply(this, args);
console.log(`Method ${propertyKey} returned: ${result}`);
return result;
};
return descriptor;
}
class MyClass {
constructor(name) {
this.name = name;
}
@LogMethod
add(a, b) {
return a + b;
}
}
const instance = new MyClass("Bob");
instance.add(5, 3);
ããã§ã¯ã@LogMethodãaddã¡ãœããããã³ã¬ãŒãããã¡ãœããã«æž¡ãããåŒæ°ãšãã®æ»ãå€ããã°ã«èšé²ããŸãã
äžè¬çãªã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãã¿ãŒã³
ã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒã¯ãããŸããŸãªãã¶ã€ã³ãã¿ãŒã³ãå®è£ ããã¢ãžã¥ãŒã«ã«æšªæçé¢å¿äºã远å ããããã«äœ¿çšã§ããŸããäžè¬çãªäŸãããã€ã玹ä»ããŸãã
1. ãã®ã³ã°ãã³ã¬ãŒã¿ãŒ
åã®äŸã§ç€ºããããã«ããã®ã³ã°ãã³ã¬ãŒã¿ãŒã¯ã¢ãžã¥ãŒã«ã«ãã®ã³ã°æ©èœã远å ãããã®æ¯ãèããããã©ãŒãã³ã¹ã«é¢ããæŽå¯ãæäŸããŸããããã¯ãã¢ããªã±ãŒã·ã§ã³ã®ãããã°ãšç£èŠã«éåžžã«åœ¹ç«ã¡ãŸãã
äŸ: ãã®ã³ã°ãã³ã¬ãŒã¿ãŒã¯ã颿°åŒã³åºããåŒæ°ãæ»ãå€ãå®è¡æéãªã©ãäžå€®ã®ãã®ã³ã°ãµãŒãã¹ã«èšé²ã§ããŸããããã¯ãè€æ°ã®ãµãŒãã¹éã§ãªã¯ãšã¹ãããã¬ãŒã¹ããããšãäžå¯æ¬ ãªåæ£ã·ã¹ãã ããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã§ç¹ã«äŸ¡å€ããããŸãã
2. ãã£ãã·ã³ã°ãã³ã¬ãŒã¿ãŒ
ãã£ãã·ã³ã°ãã³ã¬ãŒã¿ãŒã¯ãã³ã¹ãã®é«ã颿°åŒã³åºãã®çµæããã£ãã·ã¥ããåãå€ãç¹°ãè¿ãåèšç®ããå¿ èŠãæžããããšã§ããã©ãŒãã³ã¹ãåäžãããŸãã
function cacheDecorator(func) {
const cache = new Map();
return function(...args) {
const key = JSON.stringify(args);
if (cache.has(key)) {
console.log("Fetching from cache");
return cache.get(key);
}
const result = func.apply(this, args);
cache.set(key, result);
return result;
};
}
function expensiveCalculation(n) {
console.log("Performing expensive calculation");
// Simulate a time-consuming operation
let result = 0;
for (let i = 0; i < n; i++) {
result += Math.sqrt(i);
}
return result;
}
const cachedCalculation = cacheDecorator(expensiveCalculation);
console.log(cachedCalculation(1000));
console.log(cachedCalculation(1000)); // Fetches from cache
åœéåã®äŸ: çºæ¿ã¬ãŒãã衚瀺ããå¿ èŠãããã¢ããªã±ãŒã·ã§ã³ãèããŠã¿ãŸãããããã£ãã·ã³ã°ãã³ã¬ãŒã¿ãŒã¯ãé貚æç®ãµãŒãã¹ãžã®APIåŒã³åºãã®çµæãä¿åããããšãã§ãããªã¯ãšã¹ãæ°ãæžãããç¹ã«ã€ã³ã¿ãŒãããæ¥ç¶ãé ããŠãŒã¶ãŒãã¬ã€ãã³ã·ãŒã®é«ãå°åã®ãŠãŒã¶ãŒã«ãšã£ãŠãŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãåäžãããŸãã
3. èªèšŒãã³ã¬ãŒã¿ãŒ
èªèšŒãã³ã¬ãŒã¿ãŒã¯ããŠãŒã¶ãŒã®èªèšŒã¹ããŒã¿ã¹ã«åºã¥ããŠç¹å®ã®ã¢ãžã¥ãŒã«ã颿°ãžã®ã¢ã¯ã»ã¹ãå¶éããŸããããã¯ãã¢ããªã±ãŒã·ã§ã³ãä¿è·ããäžæ£ã¢ã¯ã»ã¹ãé²ãã®ã«åœ¹ç«ã¡ãŸãã
function authenticationDecorator(func) {
return function(...args) {
if (isAuthenticated()) { // Replace with your authentication logic
return func.apply(this, args);
} else {
console.log("Authentication required");
return null; // Or throw an error
}
};
}
function isAuthenticated() {
// Replace with your actual authentication check
return true; // For demonstration purposes
}
function sensitiveOperation() {
console.log("Performing sensitive operation");
}
const authenticatedOperation = authenticationDecorator(sensitiveOperation);
authenticatedOperation();
ã°ããŒãã«ã³ã³ããã¹ã: ã°ããŒãã«ãªeã³ããŒã¹ãã©ãããã©ãŒã ã§ã¯ãèªèšŒãã³ã¬ãŒã¿ãŒã䜿çšããŠã泚æç®¡çæ©èœãžã®ã¢ã¯ã»ã¹ãæ¿èªãããåŸæ¥å¡ã®ã¿ã«å¶éã§ããŸããisAuthenticated()颿°ã¯ããã©ãããã©ãŒã ã®ã»ãã¥ãªãã£ã¢ãã«ã«åºã¥ããŠãŠãŒã¶ãŒã®ããŒã«ãšæš©éããã§ãã¯ããå¿
èŠããããŸããããã¯å°åã®èŠå¶ã«ãã£ãŠç°ãªãå ŽåããããŸãã
4. ããªããŒã·ã§ã³ãã³ã¬ãŒã¿ãŒ
ããªããŒã·ã§ã³ãã³ã¬ãŒã¿ãŒã¯ãå®è¡åã«åŒæ°ã®å ¥åãã©ã¡ãŒã¿ãŒãæ€èšŒããããŒã¿ã®æŽåæ§ã確ä¿ããŠãšã©ãŒãé²ããŸãã
function validationDecorator(validator) {
return function(func) {
return function(...args) {
const validationResult = validator(args);
if (validationResult.isValid) {
return func.apply(this, args);
} else {
console.error("Validation failed:", validationResult.errorMessage);
throw new Error(validationResult.errorMessage);
}
};
};
}
function createUserValidator(args) {
const [username, email] = args;
if (!username) {
return { isValid: false, errorMessage: "Username is required" };
}
if (!email.includes("@")) {
return { isValid: false, errorMessage: "Invalid email format" };
}
return { isValid: true };
}
function createUser(username, email) {
console.log(`Creating user with username: ${username} and email: ${email}`);
}
const validatedCreateUser = validationDecorator(createUserValidator)(createUser);
validatedCreateUser("john.doe", "john.doe@example.com");
validatedCreateUser("jane", "invalid-email");
ããŒã«ãªãŒãŒã·ã§ã³ãšããªããŒã·ã§ã³: ããªããŒã·ã§ã³ãã³ã¬ãŒã¿ãŒã¯ãã°ããŒãã«ãªäœæãã©ãŒã ã§ãŠãŒã¶ãŒã®åœã«åºã¥ããŠéµäŸ¿çªå·ãæ€èšŒããããã«äœ¿çšã§ããŸããvalidator颿°ã¯ãå€éšAPIãŸãã¯èšå®ãã¡ã€ã«ããååŸãããå¯èœæ§ã®ããåœåºæã®ããªããŒã·ã§ã³ã«ãŒã«ã䜿çšããå¿
èŠããããŸããããã«ãããäœæããŒã¿ãåå°åã®éµäŸ¿èŠä»¶ãšäžèŽããŠããããšãä¿èšŒãããŸãã
5. ãªãã©ã€ãã³ã¬ãŒã¿ãŒ
ãªãã©ã€ãã³ã¬ãŒã¿ãŒã¯ã颿°åŒã³åºãã倱æããå Žåã«èªåçã«å詊è¡ããç¹ã«ä¿¡é Œæ§ã®äœããµãŒãã¹ããããã¯ãŒã¯æ¥ç¶ãæ±ãå Žåã«ãã¢ããªã±ãŒã·ã§ã³ã®å埩åãåäžãããŸãã
function retryDecorator(maxRetries) {
return function(func) {
return async function(...args) {
let retries = 0;
while (retries < maxRetries) {
try {
const result = await func.apply(this, args);
return result;
} catch (error) {
console.error(`Attempt ${retries + 1} failed:`, error);
retries++;
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1 second before retrying
}
}
throw new Error(`Function failed after ${maxRetries} retries`);
};
};
}
async function fetchData() {
// Simulate a function that might fail
if (Math.random() < 0.5) {
throw new Error("Failed to fetch data");
}
return "Data fetched successfully!";
}
const retryFetchData = retryDecorator(3)(fetchData);
retryFetchData()
.then(data => console.log(data))
.catch(error => console.error("Final error:", error));
ãããã¯ãŒã¯ã®å埩å: ã€ã³ã¿ãŒãããæ¥ç¶ãäžå®å®ãªå°åã§ã¯ããªãã©ã€ãã³ã¬ãŒã¿ãŒã¯ã泚æã®éä¿¡ãããŒã¿ã®ä¿åãªã©ã®éèŠãªæäœãæçµçã«æåããããšãä¿èšŒããäžã§éåžžã«è²Žéã§ããå詊è¡åæ°ãšå詊è¡éã®é å»¶ã¯ãç¹å®ã®ç°å¢ãšæäœã®æ©å¯æ§ã«åºã¥ããŠæ§æå¯èœã§ããã¹ãã§ãã
é«åºŠãªãã¯ããã¯
ãã³ã¬ãŒã¿ãŒã®çµã¿åãã
ãã³ã¬ãŒã¿ãŒãçµã¿åãããŠãåäžã®ã¢ãžã¥ãŒã«ã«è€æ°ã®æ©èœåŒ·åãé©çšã§ããŸããããã«ãããå ã®ã¢ãžã¥ãŒã«ã®ã³ãŒãã倿Žããããšãªããè€éã§é«åºŠã«ã«ã¹ã¿ãã€ãºãããæ¯ãèããäœæã§ããŸãã
//Requires transpilation (Babel/Typescript)
function ReadOnly(target, name, descriptor) {
descriptor.writable = false;
return descriptor;
}
function Trace(target, name, descriptor) {
const original = descriptor.value;
descriptor.value = function (...args) {
console.log(`TRACE: Calling ${name} with arguments: ${args}`);
const result = original.apply(this, args);
console.log(`TRACE: ${name} returned: ${result}`);
return result;
};
return descriptor;
}
class Calculator {
constructor(value) {
this.value = value;
}
@Trace
add(amount) {
this.value += amount;
return this.value;
}
@ReadOnly
@Trace
getValue() {
return this.value;
}
}
const calc = new Calculator(10);
calc.add(5); // Output will include TRACE messages
console.log(calc.getValue()); // Output will include TRACE messages
try{
calc.getValue = function(){ return "hacked!"; }
} catch(e){
console.log("Cannot overwrite ReadOnly property");
}
ãã³ã¬ãŒã¿ãŒãã¡ã¯ããªãŒ
ãã³ã¬ãŒã¿ãŒãã¡ã¯ããªãŒãšã¯ããã³ã¬ãŒã¿ãŒãè¿ã颿°ã§ããããã«ããããã³ã¬ãŒã¿ãŒããã©ã¡ãŒã¿ãŒåããç¹å®ã®èŠä»¶ã«åºã¥ããŠãã®æ¯ãèããæ§æã§ããŸãã
function retryDecoratorFactory(maxRetries, delay) {
return function(func) {
return async function(...args) {
let retries = 0;
while (retries < maxRetries) {
try {
const result = await func.apply(this, args);
return result;
} catch (error) {
console.error(`Attempt ${retries + 1} failed:`, error);
retries++;
await new Promise(resolve => setTimeout(resolve, delay));
}
}
throw new Error(`Function failed after ${maxRetries} retries`);
};
};
}
// Use the factory to create a retry decorator with specific parameters
const retryFetchData = retryDecoratorFactory(5, 2000)(fetchData);
èæ ®äºé ãšãã¹ããã©ã¯ãã£ã¹
- ESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ãçè§£ãã: ESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ã䜿çšããå Žåã¯ããã®æ§æãšã»ãã³ãã£ã¯ã¹ã«æ £ããŠãã ããããŸã ããããŒã¶ã«æ®µéã§ãããå°æ¥å€æŽãããå¯èœæ§ãããããšã«æ³šæããŠãã ããã
- ãã©ã³ã¹ãã€ã©ãŒã䜿çšãã: ESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ã䜿çšããå Žåã¯ãã³ãŒãããã©ãŠã¶äºæã®åœ¢åŒã«å€æããããã«ãBabelãTypeScriptãªã©ã®ãã©ã³ã¹ãã€ã©ãŒãå¿ èŠã§ãã
- é床ãªäœ¿çšãé¿ãã: ãã³ã¬ãŒã¿ãŒã¯åŒ·åã§ãããé床ã«äœ¿çšããªãããã«ããŠãã ããããã³ã¬ãŒã¿ãŒãå€ããããšãã³ãŒããçè§£ãã«ãããªãããããã°ãå°é£ã«ãªãå¯èœæ§ããããŸãã
- ãã³ã¬ãŒã¿ãŒã®çŠç¹ãçµã: åãã³ã¬ãŒã¿ãŒã¯ãåäžã®æç¢ºã«å®çŸ©ãããç®çãæã€ã¹ãã§ããããã«ãããçè§£ãšåå©çšã容æã«ãªããŸãã
- ãã³ã¬ãŒã¿ãŒããã¹ããã: ãã³ã¬ãŒã¿ãŒãæåŸ ã©ããã«æ©èœãããã°ãå°å ¥ããŠããªãããšã確èªããããã«ã培åºçã«ãã¹ãããŠãã ããã
- ãã³ã¬ãŒã¿ãŒãææžåãã: ãã³ã¬ãŒã¿ãŒã®ç®çãäœ¿çšæ³ãããã³æœåšçãªå¯äœçšãæç¢ºã«ææžåããŠãã ããã
- ããã©ãŒãã³ã¹ãèæ ®ãã: ãã³ã¬ãŒã¿ãŒã¯ã³ãŒãã«ãªãŒããŒãããã远å ããå¯èœæ§ããããŸããç¹ã«é »ç¹ã«åŒã³åºããã颿°ããã³ã¬ãŒãããå Žåã¯ãããã©ãŒãã³ã¹ãžã®åœ±é¿ã«æ³šæããŠãã ãããé©åãªå Žåã¯ãã£ãã·ã¥æè¡ã䜿çšããŠãã ããã
å®äžçã®äŸ
ã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒã¯ã以äžãå«ãããŸããŸãªå®äžçã®ã·ããªãªã«é©çšã§ããŸãã
- ãã¬ãŒã ã¯ãŒã¯ãšã©ã€ãã©ãª: å€ãã®ææ°ã®JavaScriptãã¬ãŒã ã¯ãŒã¯ãã©ã€ãã©ãªã¯ãäŸåæ§æ³šå ¥ãã«ãŒãã£ã³ã°ãç¶æ 管çãªã©ã®æ©èœãæäŸããããã«ãã³ã¬ãŒã¿ãŒãåºç¯å²ã«äœ¿çšããŠããŸããäŸãã°ãAngularã¯ãã³ã¬ãŒã¿ãŒã«å€§ããäŸåããŠããŸãã
- APIã¯ã©ã€ã¢ã³ã: ãã³ã¬ãŒã¿ãŒã¯ãAPIã¯ã©ã€ã¢ã³ã颿°ã«ãã®ã³ã°ããã£ãã·ã³ã°ãèªèšŒã远å ããããã«äœ¿çšã§ããŸãã
- ããŒã¿ããªããŒã·ã§ã³: ãã³ã¬ãŒã¿ãŒã¯ãããŒã¿ãããŒã¿ããŒã¹ã«ä¿åãããåãAPIã«éä¿¡ãããåã«ããŒã¿ãæ€èšŒããããã«äœ¿çšã§ããŸãã
- ã€ãã³ãåŠç: ãã³ã¬ãŒã¿ãŒã¯ãã€ãã³ãåŠçããžãã¯ãç°¡çŽ åããããã«äœ¿çšã§ããŸãã
çµè«
JavaScriptã¢ãžã¥ãŒã«ãã³ã¬ãŒã¿ãŒãã¿ãŒã³ã¯ãã³ãŒãã®æ¯ãèãã匷åããåå©çšæ§ãä¿å®æ§ããã¹ãå®¹ææ§ãä¿é²ãã匷åã§æè»ãªæ¹æ³ãæäŸããŸãããã®èšäºã§è°è«ãããã³ã¢ã³ã³ã»ãããçè§£ãããã¿ãŒã³ãé©çšããããšã§ãããã¯ãªãŒã³ã§å ç¢ããããŠã¹ã±ãŒã©ãã«ãªJavaScriptã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸããESãã³ã¬ãŒã¿ãŒããããŒã¶ã«ãåºãæ¡çšãããã«ã€ããŠããã®æè¡ã¯ã¢ãã³ãªJavaScriptéçºã«ãããŠããã«æ®åããã§ãããããããã®ãã¿ãŒã³ãæ¢æ±ããå®éšãããããžã§ã¯ãã«çµã¿èŸŒãããšã§ãã³ãŒããæ¬¡ã®ã¬ãã«ã«åŒãäžããŠãã ããããããžã§ã¯ãã®ç¹å®ã®ããŒãºã«åãããŠç¬èªã®ã«ã¹ã¿ã ãã³ã¬ãŒã¿ãŒãäœæããããšãæããªãã§ãã ããã